﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cars
{
    public class Keyboard
    {
        public ConsoleKey PressedKey { get; private set; }

        public void ProcessInput()
        {
            if(Console.KeyAvailable)
            {
                this.PressedKey = Console.ReadKey().Key;

                if(this.PressedKey == ConsoleKey.LeftArrow || this.PressedKey == ConsoleKey.RightArrow)
                {
                    if(onKeyPress != null)
                    {
                        onKeyPress.Invoke(this, null);
                    }
                }

            }
        }
        
        public EventHandler onKeyPress;
    }
}
